package com.to.aboomy.bannersample.pagetransformer;

import com.bumptech.glide.util.LogUtil;
import com.to.aboomy.banner.BannerViewPager;
import ohos.agp.components.Component;

import static com.to.aboomy.banner.BannerViewPager.PageType.PREVIOUS;


/**
 * @author xujianhong
 * @since 2021-08-04
 */
public class AccordionTransformer implements BannerViewPager.PageTransformer {

    @Override
    public void transformerPage(BannerViewPager.PageType pageType, Component page, float offset, float offsetPixels) {
        switch (pageType) {
            case PREVIOUS:
                page.setScaleX(1F);

                break;
            case CURRENT:
                System.out.println("fuck======CURRENT");
                if (offsetPixels > 0) {
                    page.setPivotX(page.getWidth());
                    page.setScaleX(1.0f - offset);
                    LogUtil.error("AccordionTransformer", "CURRENT左滑");
                } else {
                    page.setPivotX(0f);
                    page.setScaleX(1-offset);
                    LogUtil.error("AccordionTransformer", "CURRENT右滑");
                }
                break;
            case NEXT:
                if (offsetPixels > 0) {
                    page.setPivotX(0);
                    page.setScaleX(offset);
                    LogUtil.error("AccordionTransformer", "NEXT左滑");
                }else{
                    page.setPivotX(page.getWidth());
                    page.setScaleX(offset);
                    LogUtil.error("AccordionTransformer", "NEXT左滑");
                }
                break;
            case OTHER:
                page.setScaleX(1F);
                break;
        }
    }
}
